
function init(){
    let img_url = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1596863046159&di=fc919981caefb221c552751526cb57b1&imgtype=0&src=http%3A%2F%2Fm.cqwanqu.com%2Fupfiles%2Fimage%2F20190402%2F20190402145929_5355.jpg"
    console.log(`%c
    `,
        ` font-size:350px; background:url(${img_url}) 
      no-repeat  
    `);
}
// var wx:any=wx?wx:{};
// init()
module.exports= {
    getData(e: any) {
        return e.currentTarget.dataset
    },
    testData(e: any) {
        let json = {
            currentTarget: {
                dataset: e
            }
        }
        return json
    },
    go(e: any) {
      
        var url = typeof (e) == "string" ? e : this.getData(e).url;
        wx.navigateTo({
            url: url,
            fail: function (e) {
                console.log(e);
                console.log(url);
                var url_arr = url.split("?")
                var arr = url_arr[1].split("&");
                console.log(arr);
                var opt = {};
                for (var index = 0; index < arr.length; index++) {
                    var element = arr[index];
                    var key = element.split("=")[0];
                    var val = element.split("=")[1];
                    opt[key] = val;
                }
                getApp().globalData.opt = opt;
                console.log(opt);
                wx.switchTab({
                    url: url_arr[0]
                });
                 

            }
        });
    },
    count_down(flg:number){
        setTimeout(() => {
            if (flg > 0) {
                this.setData({
                    count_down:flg-=1
                })
                this.count_down(flg)
            }
        }, 1000);
    },
    $setData(e:any){
        this.setData({ 
            ...e.currentTarget.dataset
        }) 
    },
    /**
     * 更新微信版本
     */
    update: function () {
        const updateManager = wx.getUpdateManager();
        updateManager.onUpdateReady(function (res:any) {
            wx.showModal({
                title: '更新提示',
                content: '新版本已经准备好，是否重启应用？',
                success: function (res:any) {
                    if (res.confirm) {
                        // 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
                        updateManager.applyUpdate()
                    }
                }
            })
        })
        updateManager.onUpdateFailed(function () {
            wx.showModal({
                title: '更新提示',
                content: '更新失败'
            })
        })
    }, async $get_copy() {
        return await new Promise((res, rev) => {
            wx.getClipboardData({
                success: res,
                fail: rev
            })
        }).then(res => {
            return res.data
        }, err => {
            console.log(err);
        })
    },
    $set_copy(data) {
        return new Promise((res, rev) => {
            wx.setClipboardData({
                data,
                success: res,
                fail: rev
            })
        }).then(res => {
            console.log("成功");
        }, err => {
            console.log("错误");
        })
    },


    test(){
        console.log(this);      
    }

}